<html>
<head><title>凌旭</title>

<meta charset="UTF-8">
</head>
<body><h1>显示在浏览器窗口的部分</h1>
<h2>后缀是html的文件中可以写任意javaScrip代码
javascript语法风格和c/java一样，唯一区别是弱类型<br>
弱类型：定义变量无需指定类型
</h2>
<script>
function bubbleSort(a, len) {
        for (var i = 1; i < len; i++) {
            for (var j = 0; j < len - i; j++) {
                if (a[j] > a[j + 1]) {
                    var tmp = a[j];
                    a[j] = a[j + 1];
                    a[j + 1] = tmp;
                }
            }
        }
    }
    a = [9, 2, 1, 3]
    bubbleSort(a, 4)
    for(var i=0;i<4;i++)
        document.write(a[i])
document.write("<hr>")
function sum(a, len) {
  var s=0;
        for(var i=0;i<len;i++)
         s=s+a[i];
              return s;
    }
 
 document.write(sum(a,4))

function  isPassStr( str){
 if(str==null||str.length<8||str.length>12)
   return false;
   var hasNum=false;
 var hasLetter=false;
 var hasLowLetter=false;
 var hasUpperLetter=false;
  for( i=0;i<str.length;i++){
      var  ch=str[i];
    if(ch>='0'&&ch<='9') hasNum=true;
     else if((ch>='a'&&ch<='z')) hasLowLetter=true;
     else if((ch>='A'&&ch<='Z')) hasUpperLetter=true;
     else return false;
}
 return hasUpperLetter&&hasLowLetter&&hasNum;
}
document.write("<hr>")
 document.write( isPassStr("12345678"))
           document.write( isPassStr("12345678a"))
 document.write( isPassStr("1234567Ea"))

 function  isNumStr( str){
  if(str==null|| str.length==0) return false;
  for( var i=0;i<str.length;i++){
 var ch=str[i];
 if(!(ch>='0'&&ch<='9')) return false;
  }
return true;
}
document.write("<hr>")
document.write(isNumStr("")+" ")
document.write(isNumStr("111a")+" ")
document.write(isNumStr("123456")+" ")

document.write("<br>")

   for (var i = 1; i <=9; i++) {
            for (var j =1; j <=i; j++) {
 document.write(j+"*"+i+"="+(i*j)+"&nbsp;&nbsp;");
}
document.write("<hr>")
}

function  insert(){
var sid=document.getElementById("sid").value;
var sname=document.getElementById("sname").value;
var sage=document.getElementById("sage").value;
var njlx=document.getElementById("njlx");

if(!isNumStr(sid)||sid<10000||sid>99999){
njlx.innerHTML="学号必须在10000~99999之间"
return false;
}
if(sname==""){
njlx.innerHTML="姓名不能为空"
return false;
}
if(!isNumStr(sage)||sage<18||sage>99){
njlx.innerHTML="年龄之间"
return false;
}
njlx.innerHTML="数据输入有效"
}
</script>
<!--divide-->
<style>
input,select{
width:100%;
display:in-line;
margin-bottom:10px;
padding:5px,5px;
}
input[type=button]:hover{
background-color:#abcd12;
}


</style>
<div style="width:80%;margin:10px auto;border:1px solid red;">
  <form action="index.jsp" onsubmit="return insert()">
<lx style="color:red" id="njlx">innerHTML</lx>

<input id="sid" name="sid" placeholder="请呼入学号（10000~99999）">
 <input id="sname" name="sname" placeholder="请输入姓名">
<input id="sage" name="sage"placeholder="请输入年龄（18~99)">
<select id="ssex" name="ssex">
 <option value=0>男</option>
 <option value=1>女</option>
</select>
<input type="submit" value="增加" >
  </form>
</div >
</body>

 
</html>
